<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
</head>
<body>

<div id="user-tb" style="padding:5px;">
	<a href="#" onclick="addUser()" class="easyui-linkbutton " data-options="iconCls:'icon-user-add',plain:true" >添加</a>
	<a href="#" class="easyui-linkbutton tngou-btn" data-options="iconCls:'icon-user-edit',plain:true,disabled:true" >编辑</a>
	<a href="#" class="easyui-linkbutton tngou-btn" id="user-linkbutton-go" data-options="iconCls:'icon-user-go',plain:true,disabled:true" >启用</a>
	<a href="#" class="easyui-linkbutton tngou-btn" id="user-linkbutton-delete" data-options="iconCls:'icon-user-delete',plain:true,disabled:true" >停用</a>					
	<span style="float:right;margin-right: 15px;"> 
		<input id="user-search" class="easyui-textbox">
	</span>
</div>
             
<!-- 右键菜单 -->
<div id="user-menu" class="easyui-menu" style="width:120px;">
	<div data-options="iconCls:'icon-user-edit'">编辑</div>		
	<div  id="pacs-menu-go"data-options="iconCls:'icon-user-go'">启用</div>		
	<div id="pacs-menu-delete"data-options="iconCls:'icon-user-delete'">关闭</div>	
</div>
	
	
	
<section  style="width:100%;height:100%;padding:0px 5px 5px 5px" >
			<table id="user-table" class="easyui-datagrid"
				style="width:100%;height:100%;"
				data-options="
            	url:'${Domain}api/user',
                rownumbers: false,   
                singleSelect: true,            
                animate: true,
                collapsible: true,
                fitColumns: true,
                pagination:true,
                emptyMsg:'没有相关成员！',
                loadMsg:'数据加载中……',
                fitColumns:true,
                pageSize:20,
                method: 'post',
                onRowContextMenu:onRowContextMenu_user,
                ">
				<thead>
					<tr>
						<th data-options="field:'',checkbox:true"></th>
						<th data-options="field:'id'">编号</th>
						<th data-options="field:'account',width:1">账号</th>
						<th data-options="field:'email',width:1">邮箱</th>
						<th data-options="field:'phone',width:1">电话</th>
						<th data-options="field:'remark',width:1">备注</th>
						<th data-options="field:'role',formatter:FRole">角色</th>
						<th data-options="field:'isuse',formatter:FIsuse">是否可用</th>						
						<th data-options="field:'time',formatter:FDatetime">添加时间</th>
					</tr>
				</thead>
		</table>
</section>
<script type="text/javascript">		
	    //禁止按钮点击，选中数据后启用
		$('#user-table').datagrid({
			onLoadSuccess : function(index, row) {//加载
				$('.tngou-btn').linkbutton('disable');
			},
			onSelect : function(index, row) {//高亮选择
				$('.tngou-btn').linkbutton('enable');
				if(row.isuse==0)
				{
					$('#user-linkbutton-delete').linkbutton('disable');
				}else
				{
					$('#user-linkbutton-go').linkbutton('disable');
				}
			}
		});
		
		
		function onRowContextMenu_user(e, rowIndex, rowData) {
			e.preventDefault();
			$('#user-table').datagrid('selectRow', rowIndex)
			$('#user-menu').menu('show', {
				left : e.pageX,
				top : e.pageY
			});
			if (rowData.isuse==0) {
				$("#user-menu").menu('disableItem',
						$('#user-menu-delete')[0]);
				$("#user-menu").menu('enableItem',
						$('#user-menu-go')[0]);
			} else {
				$("#user-menu").menu('disableItem',
						$('#user-menu-gp')[0]);
				$("#user-menu").menu('enableItem',
						$('#user-menu-delete')[0]);
			}

		}


		//添加成员
		function addUser()
		{		
			$('#tngou-win').panel('resize',{width: 600,height: 540});
			$('#tngou-win').window('open');
			$('#tngou-win').window('setTitle','添加成员');
			$('#tngou-win').window('refresh', '${Domain}my/user/add');			
		}
			
</script>



</body>
</html>